export default function ajax(url, method, data, callback) {
	var xhr = new XMLHttpRequest();
	xhr.open(method, url, true);
	xhr.onreadystatechange = function() {
		// callback(xhr);
		if (xhr.readyState === 4 && xhr.status === 200) {
			callback(xhr.responseText);
		}
	};

	let token = uni.getStorageSync("token") || ""
	xhr.setRequestHeader('Content-type', 'application/x-www-form-urlencoded');
	xhr.setRequestHeader('token', token);
	// if (method === 'POST') {
	// 	let token = uni.getStorageSync("token") || ""
	// 	xhr.setRequestHeader('Content-type', 'application/x-www-form-urlencoded');
	// 	xhr.setRequestHeader('token', token);
	// }
	xhr.send(data);
}